﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MoneyManagerNET.Presentation.ViewModel.Base;

namespace MoneyManagerNET.Presentation.ViewModel
{
    public class ReportShellViewModel :ViewModelBase<Node<ReportViewModelBase>>
    {

        public Node<ReportViewModelBase>[] ReportGroups;

        public ReportShellViewModel()
        {
            var summaryOfAccounts = new SummaryOfAccountsReportViewModel();
            var sommaryOfStocks = new SummaryOfStocksReportViewModel();

            var stocksNode = new Node<ReportViewModelBase>() { Value = summaryOfAccounts };

            var accountsNode = new Node<ReportViewModelBase>() { Value = summaryOfAccounts };
            accountsNode.Add(stocksNode);

            ReportGroups = new Node<ReportViewModelBase>[1] { accountsNode };

        }

        public override object Model
        {
            get
            {
                return base.Model;
            }
            set
            {
                base.Model = value;
                if(ModelAs!=null&&ModelAs.Value!=null)
                    ModelAs.Value.Execute();
            }
        }


        //object content;
        //public object Content {
        //    get { return content; }
        //    set { content = value; OnChange(()=>Content); }
        //}
        
    }


    public class Node<T>
    {
        public T Value { get; set; }
        List<Node<T>> _children = new List<Node<T>>();
        public Node<T>[] Children { get { return _children.ToArray(); } }
        public void Add(Node<T> item)
        {
            _children.Add(item);
        }
        public void Remove(Node<T> item)
        {
            _children.Remove(item);
        }

        public override string ToString()
        {
            return Value.ToString();
        }
    }


    

}
